package com.example.basic.enumtojson;

import com.google.gson.Gson;

import java.util.ArrayList;

public class Test {

    public static void main(String[] args) {
        ExampleObject object = new ExampleObject();
        object.type = EventType.EXCEPTION;
        object.types = new ArrayList<>();
        object.types.add(EventType.OCCURRENCE);
        object.types.add(EventType.EXCEPTION);
        object.types.add(EventType.SINGLE_INSTANCE);
        Gson gson = new Gson();
        System.out.println(gson.toJson(object));

        String jsonStr = "{\"type\":\"EXCEPTION\"}";
        ExampleObject exampleObjectFromJson = gson.fromJson(jsonStr,ExampleObject.class);
        System.out.println(exampleObjectFromJson.type);
    }

}
